#============================================================
#	Item Panel Test
#============================================================
# @datetime: 2022-3-22 22:49:50
#============================================================
extends Node


# 如果使用代码设置属性，则需要在 _enter_tree 方法下设置
onready var item_panel = $CanvasLayer/ItemPanel


func _ready():
	for i in 5:
		item_panel.add_item({
			"icon": "res://icon.png",
			"name": "Test" ,
		})
	
	var id = item_panel.add_item({
			"icon": "res://icon.png",
			"name": "Item" ,
		})
	
	for i in 10:
		item_panel.add_item({
			"icon": "res://icon.png",
			"name": "Item_%02d" % (randi() % 5) ,
		})
	
	var data = item_panel.get_item_by_type("name", "Item")
	print(JSON.print(data, '\t'))
	
	yield(get_tree().create_timer(2), "timeout")
	
	# 取出一件物品
	print(item_panel.take_item(id, 1))
	
	# 移除物品
#	item_panel.remove_item(id)


func _on_ItemPanel_added_item(id):
	pass
#	print_data(item_panel.get_item_data(id))


